gdk: add gdk_window_set_shadow_width()
authorRyan Lortie <desrt@desrt.ca>
Fri, 13 Dec 2013 03:38:12 +0000 (22:38 -0500)
committerRyan Lortie <desrt@desrt.ca>
Fri, 13 Dec 2013 04:53:47 +0000 (23:53 -0500)
And deprecate the X11-specific version of it.

We call this new API _set_shadow_width() and not _set_frame_extents()
because we already have a gdk_window_get_frame_extents() with a
different meaning and different type of value.

https://bugzilla.gnome.org/show_bug.cgi?id=720374

docs/reference/gdk/gdk3-sections.txt
gdk/gdkwindow.c
gdk/gdkwindow.h
gdk/gdkwindowimpl.h
gdk/x11/gdkwindow-x11.c
gdk/x11/gdkx11window.h
gtk/gtkwindow.c

index 8652973a7669ec9647efc0c104bdbc37faa6d519..c0962ffd157fa0e2183674452f0c873cafc5dfc3 100644 (file)
@@ -450,6 +450,7 @@ gdk_window_set_modal_hint
 gdk_window_get_modal_hint
 gdk_window_set_type_hint
 gdk_window_get_type_hint
+gdk_window_set_shadow_width
 gdk_window_set_skip_taskbar_hint
 gdk_window_set_skip_pager_hint
 gdk_window_set_urgency_hint
index a890e11ddfecea3d51951aa0d8f46fe2d55f9777..17a1125881d1c8208caa06b1db4dd42a8fbb9599 100644 (file)
@@ -10872,3 +10872,42 @@ gdk_window_set_opaque_region (GdkWindow      *window,
   if (impl_class->set_opaque_region)
     return impl_class->set_opaque_region (window, region);
 }
+
+/**
+ * gdk_window_set_shadow_width:
+ * @window: a #GdkWindow
+ * @left: The left extent
+ * @right: The right extent
+ * @top: The top extent
+ * @bottom: The bottom extent
+ *
+ * Newer GTK+ windows using client-side decorations use extra geometry
+ * around their frames for effects like shadows and invisible borders.
+ * Window managers that want to maximize windows or snap to edges need
+ * to know where the extents of the actual frame lie, so that users
+ * don't feel like windows are snapping against random invisible edges.
+ *
+ * Note that this property is automatically updated by GTK+, so this
+ * function should only be used by applications which do not use GTK+
+ * to create toplevel windows.
+ *
+ * Since: 3.12
+ */
+void
+gdk_window_set_shadow_width (GdkWindow *window,
+                             gint       left,
+                             gint       right,
+                             gint       top,
+                             gint       bottom)
+{
+  GdkWindowImplClass *impl_class;
+
+  g_return_if_fail (GDK_IS_WINDOW (window));
+  g_return_if_fail (!GDK_WINDOW_DESTROYED (window));
+  g_return_if_fail (left >= 0 && right >= 0 && top >= 0 && bottom >= 0);
+
+  impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl);
+
+  if (impl_class->set_shadow_width)
+    impl_class->set_shadow_width (window, left, right, top, bottom);
+}
index 014f2f70e87c48c15ca886f46ccb59a4f051ceca..0d89782cf06367a2e458441db3866d86f78681fc 100644 (file)
@@ -1096,6 +1096,13 @@ void       gdk_window_set_event_compression    (GdkWindow      *window,
 GDK_AVAILABLE_IN_3_12
 gboolean   gdk_window_get_event_compression    (GdkWindow      *window);
 
+GDK_AVAILABLE_IN_3_12
+void       gdk_window_set_shadow_width         (GdkWindow      *window,
+                                                gint            left,
+                                                gint            right,
+                                                gint            top,
+                                                gint            bottom);
+
 G_END_DECLS
 
 #endif /* __GDK_WINDOW_H__ */
index b0b43b9105581d515f9c5ffa2242278fd4c7d830..ab04985c9844581791e590505eb9d81c36ef38b6 100644 (file)
@@ -295,6 +295,11 @@ struct _GdkWindowImplClass
 
   void         (* set_opaque_region)      (GdkWindow      *window,
                                            cairo_region_t *region);
+  void         (* set_shadow_width)       (GdkWindow      *window,
+                                           gint            left,
+                                           gint            right,
+                                           gint            top,
+                                           gint            bottom);
 };
 
 /* Interface Functions */
index 5b51db33132dd7b3559e925af555cb901dadced3..63ecf1417328e36230b14deafe68edfff24a270c 100644 (file)
@@ -3660,6 +3660,25 @@ gdk_x11_window_set_hide_titlebar_when_maximized (GdkWindow *window,
     }
 }
 
+static void
+gdk_x11_window_set_shadow_width (GdkWindow *window,
+                                 int        left,
+                                 int        right,
+                                 int        top,
+                                 int        bottom)
+{
+  Atom frame_extents;
+  gulong data[4] = { left, right, top, bottom };
+
+  frame_extents = gdk_x11_get_xatom_by_name_for_display (gdk_window_get_display (window),
+                                                         "_GTK_FRAME_EXTENTS");
+  XChangeProperty (GDK_WINDOW_XDISPLAY (window),
+                   GDK_WINDOW_XID (window),
+                   frame_extents, XA_CARDINAL,
+                   32, PropModeReplace,
+                   (guchar *) &data, 4);
+}
+
 /**
  * gdk_x11_window_set_frame_extents:
  * @window: (type GdkX11Window): a #GdkWindow
@@ -3668,17 +3687,12 @@ gdk_x11_window_set_hide_titlebar_when_maximized (GdkWindow *window,
  * @top: The top extent
  * @bottom: The bottom extent
  *
- * Newer GTK+ windows using client-side decorations use extra geometry
- * around their frames for effects like shadows and invisible borders.
- * Window managers that want to maximize windows or snap to edges need
- * to know where the extents of the actual frame lie, so that users
- * don't feel like windows are snapping against random invisible edges.
- *
- * Note that this property is automatically updated by GTK+, so this
- * function should only be used by applications which do not use GTK+
- * to create toplevel windows.
+ * This is the same as gdk_window_set_shadow_width() but it only works
+ * on GdkX11Window.
  *
  * Since: 3.10
+ *
+ * Deprecated: 3.12: Use gdk_window_set_shadow_width() instead.
  */
 void
 gdk_x11_window_set_frame_extents (GdkWindow *window,
@@ -3687,16 +3701,7 @@ gdk_x11_window_set_frame_extents (GdkWindow *window,
                                   int        top,
                                   int        bottom)
 {
-  Atom frame_extents;
-  gulong data[4] = { left, right, top, bottom };
-
-  frame_extents = gdk_x11_get_xatom_by_name_for_display (gdk_window_get_display (window),
-                                                         "_GTK_FRAME_EXTENTS");
-  XChangeProperty (GDK_WINDOW_XDISPLAY (window),
-                   GDK_WINDOW_XID (window),
-                   frame_extents, XA_CARDINAL,
-                   32, PropModeReplace,
-                   (guchar *) &data, 4);
+  gdk_x11_window_set_shadow_width (window, left, right, top, bottom);
 }
 
 /**
@@ -5712,4 +5717,5 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
   impl_class->delete_property = _gdk_x11_window_delete_property;
   impl_class->get_scale_factor = gdk_x11_window_get_scale_factor;
   impl_class->set_opaque_region = gdk_x11_window_set_opaque_region;
+  impl_class->set_shadow_width = gdk_x11_window_set_shadow_width;
 }
index 8e8290c161dd3a07b73302c9513138abdcd2c0c0..1943c34245d86f971d4a349ec2b58205a7e1020d 100644 (file)
@@ -65,7 +65,7 @@ void     gdk_x11_window_set_utf8_property    (GdkWindow *window,
 GDK_AVAILABLE_IN_3_2
 void     gdk_x11_window_set_theme_variant (GdkWindow   *window,
                                            char        *variant);
-GDK_AVAILABLE_IN_3_10
+GDK_DEPRECATED_IN_3_12_FOR(gdk_window_set_shadow_width)
 void     gdk_x11_window_set_frame_extents (GdkWindow *window,
                                            int        left,
                                            int        right,
index e0dca5b98871249fc02fb3a7d64b008a838b3050..88b884cc1bb514995b3549661d2c38e45a630944 100644 (file)
@@ -6422,21 +6422,19 @@ update_border_windows (GtkWindow *window)
 }
 
 static void
-update_frame_extents (GtkWindow *window,
-                      GtkBorder *border)
+update_shadow_width (GtkWindow *window,
+                     GtkBorder *border)
 {
-#ifdef GDK_WINDOWING_X11
   GdkWindow *gdk_window;
 
   gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
 
-  if (GDK_IS_X11_WINDOW (gdk_window))
-    gdk_x11_window_set_frame_extents (gdk_window,
-                                      border->left,
-                                      border->right,
-                                      border->top,
-                                      border->bottom);
-#endif
+  if (gdk_window)
+    gdk_window_set_shadow_width (gdk_window,
+                                 border->left,
+                                 border->right,
+                                 border->top,
+                                 border->bottom);
 }
 
 static void
@@ -6571,7 +6569,7 @@ _gtk_window_set_allocation (GtkWindow           *window,
   priv->title_height = 0;
 
   if (priv->client_decorated)
-    update_frame_extents (window, &window_border);
+    update_shadow_width (window, &window_border);
 
   update_opaque_region (window, &window_border, &child_allocation);